#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "logika.h"
#include "node.h"
#include "lessnode.h"
#include <set>
#include <algorithm>
#include <QDebug>

struct printNode : std::unary_function<Node*, void> {
	void operator()(const Node* x) const {
		qDebug()<<"heft"<<x->heft<<"kod"<<x->kod;
	}
};

MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow),
	alg (new Algorithms(this)){
	ui->setupUi(this);

	std::multiset<Node*, lessNode> HafmanTree;
	HafmanTree.insert(new Node(5, this));
	HafmanTree.insert(new Node(43, this));
	HafmanTree.insert(new Node(6, this));
	HafmanTree.insert(new Node(3, this));
	HafmanTree.insert(new Node(654, this));
	HafmanTree.insert(new Node(3, true, this));

	std::for_each(HafmanTree.begin(), HafmanTree.end(), printNode());
}

MainWindow::~MainWindow(){
	delete ui;
}
